package day22.edu;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Scanner;

// Created: 22/09/2025, ChangJiang Ru
public class ListTest {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        Scanner scan = new Scanner(System.in);

        // Requirement: 'a' - 'z'
        for (int i = 0; i < 30; i++) {

            list.add((char)(Math.random()*(122 - 97 + 1) + 97) + "");
        }
        /*
        for(Object obj : list)
        {
            System.out.println(obj);
        }

         */
        System.out.println(list);

        while(true)
        {
            System.out.print("Please input you want check letter: ");
            String str = scan.next();
            if(str.equals("-1"))
            {
                break;
            }
            int count = listTest(list, str);
            System.out.println(str + ": " + count);
        }
    }
    // Requirement 2:
    public static int listTest(Collection list, String s)
    {
        int count = 0;
        for(Object obj : list)
        {
            if(s.equals(obj))
            {
                count++;
            }
        }
        return count;
    }
}
